<template>
  <div id="app">
    <el-row>
      <div class="title">添加商户</div>
      <div class="title_box">
        <el-col :span="24">
          <el-steps :active="active" align-center>
            <el-step title="基本信息"></el-step>
            <el-step title="运营信息"></el-step>
            <el-step title="费率信息"></el-step>
            <el-step title="结算信息"></el-step>
          </el-steps>
        </el-col>
      </div>
    </el-row>
    <div>
      <div class="text">基本信息</div>
      <el-form class="form_box" :model="form">
        <el-row>
          <el-col :span="24">
            <el-form-item label="商户类型：">
              <el-radio-group class="width_90" v-model="form.radio">
                <el-radio :label="3">小微商户</el-radio>
                <el-radio :label="6">个体工商户</el-radio>
                <el-radio :label="9">企业</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="商户类型：">
              <el-select v-model="form.merchant_types" placeholder="请选择">
                <el-option label="超市" value="1"> </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="商户全称">
              <el-input
                v-model="form.name"
                placeholder="请输入商户全称"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="经营名称：">
              <el-input
                v-model="form.manage_name"
                placeholder="请输入经营名称"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="经营类目：">
              <el-select v-model="form.category" placeholder="请选择经营类目">
                <el-option label="母婴" value="1"> </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="详细地址：">
              <el-input
                v-model="form.detail_address"
                placeholder="请输入详细地址"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="联系人姓名：">
              <el-input
                v-model="form.contact_name"
                placeholder="请输入联系人姓名"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="联系人手机号：">
              <el-input
                v-model="form.contact_phone"
                placeholder="请输入联系人手机号"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="支付类型：">
              <el-checkbox-group v-model="form.pay_type">
                <el-checkbox :label="1">ERP</el-checkbox>
                <el-checkbox :label="1">插件</el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="经营场地：">
              <div class="display_flex max_box">
                <div class="father_box" style="margin-right: 20px">
                  <div v-if="form.door_img" class="item_box">
                    <i
                      @click="see_icon(form.door_img)"
                      class="el-icon-zoom-in"
                    ></i>
                    <i @click="del_icon(2)" class="el-icon-delete"></i>
                  </div>

                  <img
                    v-if="form.door_img"
                    class="img_up_item"
                    :src="form.door_img"
                    alt=""
                  />
                  <el-upload
                    v-else
                    action="https://jsonplaceholder.typicode.com/posts/"
                    class="img_up_item avatar-uploader"
                    :http-request="uploadFile1"
                    :show-file-list="false"
                  >
                    <img
                      class="img_up_item"
                      v-if="!form.door_img"
                      src="../../assets/images/Merchantmeal/mentou.png"
                    />
                  </el-upload>
                </div>
                <div class="father_box" style="margin-right: 20px">
                  <div v-if="form.place_img" class="item_box">
                    <i
                      @click="see_icon(form.place_img)"
                      class="el-icon-zoom-in"
                    ></i>
                    <i @click="del_icon(3)" class="el-icon-delete"></i>
                  </div>

                  <img
                    v-if="form.place_img"
                    class="img_up_item"
                    :src="form.place_img"
                    alt=""
                  />
                  <el-upload
                    v-else
                    action="https://jsonplaceholder.typicode.com/posts/"
                    class="img_up_item avatar-uploader"
                    :http-request="uploadFile2"
                    :show-file-list="false"
                  >
                    <img
                      class="img_up_item"
                      v-if="!form.place_img"
                      src="../../assets/images/Merchantmeal/csn.png"
                    />
                  </el-upload>
                </div>
                <div class="father_box">
                  <div v-if="form.cashier_img" class="item_box">
                    <i
                      @click="see_icon(form.cashier_img)"
                      class="el-icon-zoom-in"
                    ></i>
                    <i @click="del_icon(3)" class="el-icon-delete"></i>
                  </div>

                  <img
                    v-if="form.cashier_img"
                    class="img_up_item"
                    :src="form.cashier_img"
                    alt=""
                  />
                  <el-upload
                    v-else
                    action="https://jsonplaceholder.typicode.com/posts/"
                    class="img_up_item avatar-uploader"
                    :http-request="uploadFile3"
                    :show-file-list="false"
                  >
                    <img
                      class="img_up_item"
                      v-if="!form.cashier_img"
                      src="../../assets/images/Merchantmeal/shouyin.png"
                    />
                  </el-upload>
                </div>
              </div>

              <div class="tetx_ges">
                格式要求：支持jpg,jpeg,png格式，大小不超过10M
              </div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="商户标识：">
              <div class="display_flex">
                <div class="father_box">
                  <div v-if="form.headimg" class="item_box">
                    <i
                      @click="see_icon(form.headimg)"
                      class="el-icon-zoom-in"
                    ></i>
                    <i @click="del_icon(2)" class="el-icon-delete"></i>
                  </div>

                  <img
                    v-if="form.headimg"
                    class="img_up_item"
                    :src="form.headimg"
                    alt=""
                  />
                  <el-upload
                    v-else
                    action="https://jsonplaceholder.typicode.com/posts/"
                    class="img_up_item avatar-uploader"
                    :http-request="uploadFile4"
                    :show-file-list="false"
                  >
                    <img
                      class="img_up_item"
                      v-if="!form.headimg"
                      src="../../assets/images/Merchantmeal/mentou.png"
                    />
                  </el-upload>
                </div>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
  </div>
</template>
<script>
export default {
  data () {
    return {
      active: 1,
      form: {
        radio: "",
        merchant_types: "",
        name: "",
        manage_name: "",
        category: "",
        detail_address: "",
        contact_name: "",
        contact_phone: "",
        pay_type: [],
        door_img: "",
        place_img: "",
        cashier_img: "",
        headimg: ""
      }
    }
  },
  methods: {
    add () {
      this.active++
    },
    uploadFile (formData, options) {
      console.log("上传照片", formData, "照片类型", options)
      if (options == 1) {
        this.accountForm.bank_just =
          "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
      } else if (options == 2) {
        this.accountForm.id_card_photo1 =
          "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
      } else if (options == 3) {
        this.accountForm.id_card_photo2 =
          "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
      } else if (options == 4) {
        this.accountForm.personal_icon =
          "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
      }
      this.accountForm = Object.assign({}, this.accountForm)
    },
    // 上传照片
    uploadFile1 (res, file) {
      console.log(111)
      let istype =
        res.file.type == "image/jpeg" ||
        res.file.type == "image/png" ||
        res.file.type == "image/jpg"
      if (!istype) {
        return tipsFun(this, "error", "只能上传JPG、PNG、JPEG格式文件")
      }
      if (res.file.size < 1) {
        return tipsFun(this, "error", "文件大小错误")
      }
      let formData = new FormData()
      formData.append("image", res.file)
      this.uploadFile(formData, 1)
    },
    uploadFile2 (res, file) {
      let istype =
        res.file.type == "image/jpeg" ||
        res.file.type == "image/png" ||
        res.file.type == "image/jpg"
      if (!istype) {
        return tipsFun(this, "error", "只能上传JPG、PNG、JPEG格式文件")
      }
      if (res.file.size < 1) {
        return tipsFun(this, "error", "文件大小错误")
      }
      let formData = new FormData()
      formData.append("image", res.file)
      this.uploadFile(formData, 2)
    },
    uploadFile3 (res, file) {
      let istype =
        res.file.type == "image/jpeg" ||
        res.file.type == "image/png" ||
        res.file.type == "image/jpg"
      if (!istype) {
        return tipsFun(this, "error", "只能上传JPG、PNG、JPEG格式文件")
      }
      if (res.file.size < 1) {
        return tipsFun(this, "error", "文件大小错误")
      }
      let formData = new FormData()
      formData.append("image", res.file)
      this.uploadFile(formData, 3)
    },
    uploadFile4 (res, file) {
      let istype =
        res.file.type == "image/jpeg" ||
        res.file.type == "image/png" ||
        res.file.type == "image/jpg"
      if (!istype) {
        return tipsFun(this, "error", "只能上传JPG、PNG、JPEG格式文件")
      }
      if (res.file.size < 1) {
        return tipsFun(this, "error", "文件大小错误")
      }
      let formData = new FormData()
      formData.append("image", res.file)
      this.uploadFile(formData, 4)
    }
  }
}
</script>

<style scoped>
.form_box #app {
  background-color: #fff;
}
.width_90 {
  width: 90%;
}
.title {
  margin: 20px;
  font-size: 18px;
  font-family: PingFang SC-Medium, PingFang SC;
  font-weight: 500;
  color: #413f3f;
}
.title_box {
  height: 12vh;
  padding: 10px 0;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #d9d9d9;
}
.text {
  font-size: 16px;
  font-family: PingFang SC-Bold, PingFang SC;
  font-weight: bold;
  color: #2c2c2c;
}
.tetx_ges {
  font-size: 14px;
  font-family: PingFang SC-Medium, PingFang SC;
  font-weight: 500;
  color: #555353;
}
.img_up_item {
  width: 86px;
  height: 86px;
  border-radius: 8px;
}
.father_box {
  width: 86px;
  height: 86px;
  position: relative;
}
.item_box {
  width: 86px;
  height: 86px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  color: #fff;
  z-index: 111;
  background-color: rgba(0, 0, 0, 0.5);
}
</style>
